import 'package:finance_app/src/entities/sub_billing_item_entity.dart';
import 'package:finance_app/src/utils/date_time_utils.dart';

subBillingItemEntityFromJson(SubBillingItemEntity data, Map<String, dynamic> json) {
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['coupon_id'] != null) {
		data.couponId = json['coupon_id'];
	}
	if (json['user_id'] != null) {
		data.userId = json['user_id'] is String
				? int.tryParse(json['user_id'])
				: json['user_id'].toInt();
	}
	if (json['payment_gateway_id'] != null) {
		data.paymentGatewayId = json['payment_gateway_id'];
	}
	if (json['company_id'] != null) {
		data.companyId = json['company_id'] is String
				? int.tryParse(json['company_id'])
				: json['company_id'].toInt();
	}
	if (json['company_name'] != null) {
		data.companyName = json['company_name'].toString();
	}
	if (json['plan_id'] != null) {
		data.planId = json['plan_id'] is String
				? int.tryParse(json['plan_id'])
				: json['plan_id'].toInt();
	}
	if (json['plan_name'] != null) {
		data.planName = json['plan_name'].toString();
	}
	if (json['start_at'] != null) {
		data.startAt = json['start_at'].toString();
	}
	if (json['end_at'] != null) {
		data.endAt = json['end_at'].toString();
	}
	if (json['issued_at'] != null) {
		data.issuedAt = json['issued_at'].toString();
	}
	if (json['due_at'] != null) {
		data.dueAt = json['due_at'];
	}
	if (json['notified_at'] != null) {
		data.notifiedAt = json['notified_at'];
	}
	if (json['renew'] != null) {
		data.renew = json['renew'] is String
				? int.tryParse(json['renew'])
				: json['renew'].toInt();
	}
	if (json['bill_to_company_id'] != null) {
		data.billToCompanyId = json['bill_to_company_id'] is String
				? int.tryParse(json['bill_to_company_id'])
				: json['bill_to_company_id'].toInt();
	}
	if (json['bill_phone_number'] != null) {
		data.billPhoneNumber = json['bill_phone_number'].toString();
	}
	if (json['bill_contact_name'] != null) {
		data.billContactName = json['bill_contact_name'].toString();
	}
	if (json['bill_postal_code'] != null) {
		data.billPostalCode = json['bill_postal_code'].toString();
	}
	if (json['bill_unit_number'] != null) {
		data.billUnitNumber = json['bill_unit_number'].toString();
	}
	if (json['bill_address'] != null) {
		data.billAddress = json['bill_address'].toString();
	}
	if (json['bill_company_name'] != null) {
		data.billCompanyName = json['bill_company_name'].toString();
	}
	if (json['bill_country_code'] != null) {
		data.billCountryCode = json['bill_country_code'];
	}
	if (json['payment_gateway_status'] != null) {
		data.paymentGatewayStatus = json['payment_gateway_status'];
	}
	if (json['payment_method'] != null) {
		data.paymentMethod = json['payment_method'].toString();
	}
	if (json['card_number'] != null) {
		data.cardNumber = json['card_number'];
	}
	if (json['next_price'] != null) {
		data.nextPrice = json['next_price'] is String
				? num.tryParse(json['next_price'])
				: json['next_price'];
	}
	if (json['price'] != null) {
		data.price = json['price'] is String
				? num.tryParse(json['price'])
				: json['price'];
	}
	if (json['original_price'] != null) {
		data.originalPrice = json['original_price'] is String
				? num.tryParse(json['original_price'])
				: json['original_price'];
	}
	if (json['status'] != null) {
		data.status = json['status'].toString();
	}
	if (json['created_at'] != null) {
		data.createdAt = json['created_at'].toString();
	}
	if (json['updated_at'] != null) {
		data.updatedAt = json['updated_at'].toString();
	}
	if (json['deleted_at'] != null) {
		data.deletedAt = json['deleted_at'];
	}
	if (json['currency_code'] != null) {
		data.currencyCode = json['currency_code'].toString();
	}
	if (json['currentDate'] != null) {
		data.currentDate = json['currentDate'].toString();
	}
	return data;
}

Map<String, dynamic> subBillingItemEntityToJson(SubBillingItemEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['id'] = entity.id;
	data['coupon_id'] = entity.couponId;
	data['user_id'] = entity.userId;
	data['payment_gateway_id'] = entity.paymentGatewayId;
	data['company_id'] = entity.companyId;
	data['company_name'] = entity.companyName;
	data['plan_id'] = entity.planId;
	data['plan_name'] = entity.planName;
	data['start_at'] = entity.startAt;
	data['end_at'] = entity.endAt;
	data['issued_at'] = entity.issuedAt;
	data['due_at'] = entity.dueAt;
	data['notified_at'] = entity.notifiedAt;
	data['renew'] = entity.renew;
	data['bill_to_company_id'] = entity.billToCompanyId;
	data['bill_phone_number'] = entity.billPhoneNumber;
	data['bill_contact_name'] = entity.billContactName;
	data['bill_postal_code'] = entity.billPostalCode;
	data['bill_unit_number'] = entity.billUnitNumber;
	data['bill_address'] = entity.billAddress;
	data['bill_company_name'] = entity.billCompanyName;
	data['bill_country_code'] = entity.billCountryCode;
	data['payment_gateway_status'] = entity.paymentGatewayStatus;
	data['payment_method'] = entity.paymentMethod;
	data['card_number'] = entity.cardNumber;
	data['next_price'] = entity.nextPrice;
	data['price'] = entity.price;
	data['original_price'] = entity.originalPrice;
	data['status'] = entity.status;
	data['created_at'] = entity.createdAt;
	data['updated_at'] = entity.updatedAt;
	data['deleted_at'] = entity.deletedAt;
	data['currency_code'] = entity.currencyCode;
	data['currentDate'] = entity.currentDate;
	return data;
}